package com.example.addressbook;

import android.widget.*;
import android.view.View;
import android.view.ViewGroup;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle; 
import android.content.Intent; 
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.view.LayoutInflater;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.TabLayout;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.*;
import android.graphics.Color;

import java.util.*;

public class ListFragment2 extends Fragment{
	
	public RecyclerView recyclerView;
	public PeopleAdapter peopleAdapter;
		
	@Override
	public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState){
		View view = inflater.inflate(R.layout.list_fragment_2,container,false);
		peopleAdapter = new PeopleAdapter(getActivity());
		recyclerView = (RecyclerView)view.findViewById(R.id.recycler_view_1);
		
		FloatingActionButton fab = (FloatingActionButton)view.findViewById(R.id.floating_action_button);
		fab.setColorFilter(Color.WHITE);
		fab.setOnClickListener(new View.OnClickListener(){
			@Override
			public void onClick(View v){
				Intent  intent = new Intent(getActivity(),ModifyActivity.class);
				getActivity().startActivityForResult(intent,1);
			}
		});
		
		return view;
	}

	@Override
	public void onActivityCreated(Bundle savedInstanceState){
		super.onActivityCreated(savedInstanceState);
		recyclerView.setLayoutManager( new LinearLayoutManager(recyclerView.getContext()));
		recyclerView.setAdapter(peopleAdapter);
	}
}